package com.itheima.demo4;

import java.util.concurrent.BlockingDeque;

public class Customer implements Runnable {
    @Override
    public void run() {
        while(true) {
            synchronized (Box.lock) {
                    if (!Box.milk) {
                        try {
                            Box.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }else {

                        Box.setMilk(false);
                        Box.setX(Box.getX() - 1);
                        System.out.println("消费一瓶,还有"+Box.x+"瓶");
                        Box.lock.notifyAll();
                    }
            }
        }
    }
}
